package ucm.module;

import air_cp5620.AirInfo;
import air_cp5620.dao.DAO;
import java.sql.*;
import java.util.Vector;

public class Main_UIM {

    private DAO dbCon = null;
    public Main_UIM() {
        dbCon = new DAO();
    }


    public Vector<AirInfo> LoadDataFormDB()
    {
        String sql = null;
        Vector<AirInfo> airInfo_vec = new Vector<AirInfo>();
        Connection con = dbCon.getConnection();
        if (con == null) {
            return null;
        }
        try {
            Statement stmt = con.createStatement(ResultSet.CONCUR_UPDATABLE, ResultSet.CONCUR_UPDATABLE);
            sql = "select * from tbl_air_info where isdelete='0'";
            ResultSet res = stmt.executeQuery(sql);
            
            while(res.next())
            {
                AirInfo airinfo = new AirInfo(res.getString("id"),
                        res.getString("start_city"),
                        res.getString("end_city"),
                        res.getString("start_time"),
                        res.getString("end_time"),
                        res.getInt("ticketcount"),
                        res.getInt("price"));
                airInfo_vec.add(airinfo);
            }
        } catch (Exception e) {
            System.out.println(e);
        }
        return airInfo_vec;
    }
    
}
